package cn.wzptsoft.tinymallbe.service;

import cn.wzptsoft.tinymallbe.entity.Sku;
import cn.wzptsoft.tinymallbe.repository.SkuRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;

@Service
public class SkuService {

    @Autowired
    private SkuRepository skuRepository;

    public List<Sku> getShopCart(String ids) {
        List<Long> list = new LinkedList<>();
        if (!"".equals(ids)) {
            String[] split = ids.split(",");
            for (String s : split) {
                list.add(Long.valueOf(s));
            }
        }
        return skuRepository.findByIdIn(list);
    }
}
